/**
 * 
 */
package com.yst.metho.web.application.project.actions;

import nextapp.echo2.app.event.ActionEvent;

import com.yst.metho.web.application.SuiviProdApp;
import com.yst.metho.web.application.components.GenericEditWindow;
import com.yst.metho.web.application.components.listingview.ToolbarAction;
import com.yst.metho.web.application.project.ProjectListModel;
import com.yst.metho.web.application.project.ProjectPane;
import com.yst.metho.web.application.utils.ExceptionMgt;
import com.yst.metho.web.application.utils.Locator;
import com.yst.suivi.data.rights.Right;

/**
 * @author perso
 * 
 */
public class CreateProject extends ToolbarAction
{
	private ProjectListModel mModel;

	/**
	 * 
	 */
	private static final String CREATE_USER_COMMAND = "CreateProject";

	public CreateProject(ProjectListModel model)
	{
		super(Right.CREATE_PROJECT, "Create");
		mModel = model;
		setActionCommand(CREATE_USER_COMMAND);
		addActionListener(this);
	}

	public void actionPerformed(ActionEvent e)
	{
		if (CREATE_USER_COMMAND.equals(e.getActionCommand()))
		{
			try
			{
				ProjectPane view = new ProjectPane(Locator.getTeamView().findTeamsBean());
				GenericEditWindow window = new GenericEditWindow(view, new ModifyProjectBtn(mModel, view));
				window.setHeight(EditProjectAction.POPUP_WIDTH);
				SuiviProdApp.getApp().getDefaultWindow().getContent().add(window);
			}
			catch (Throwable t)
			{
				ExceptionMgt.manage(t);
			}
		}
	}
}
